<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			/*
		      继承:
			  子类 extends 父类 {
				  constructor(参数1, 参数2, ...) {
				  	super(参1);//调用父类的构造方法
				  }
			  }
		     
		
		
		    */
			class Person {
				constructor(name, age) {
					this.name = name;
					this.age = age;
				}

				eat() {
					console.log("吃饭");
				}
			}

			class Student extends Person {
				constructor(name, age, score) {
					// this.name = name;
					// this.age = age;
					//调用父类的构造方法
					super(name, age);
					this.score = score;
				}

				study() {
					console.log(this.name + ",好好学习");
				}
				//重写
				eat() {
					super.eat(); //调用父类的方法
					console.log("吃大餐");
				}
			}

			var stu = new Student("zhangsan", 20, 90);
			console.log(stu.name);
			console.log(stu.score);
			stu.study();
			stu.eat();


			class Worker {
				constructor(name, age, salary) {
					// this.name = name;
					// this.age = age;
					this.salary = salary;
				}
			}
		</script>
	</body>
</html>
